﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using DevExpress.XtraBars;
using DevTeam;

namespace Fatura
{
    public partial class MainForm : DevMainForm
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {

            Session.CurrentUser.RefreshYetki();
            Session.SetAdmins(4, 17, 94, 95, 284, 285, 192);
            Session.SetDevelopers(17, 94, 95, 284, 285);

            FaturaRibbon.Init();

            if (Session.Settings.SkinName != string.Empty)
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle(Session.Settings.SkinName);
            else
                DevExpress.LookAndFeel.UserLookAndFeel.Default.SetSkinStyle("Office 2013");



            //todo
            //Mail.Init();
            Session.EasyNav = new EasyNav();

            //todo
            GridViewExtensions.Binding += GridViewExtensions_Binding;
            try
            { 
                new AppSession();
            }
            catch (ApplicationException ex)
            {
                LogManager.LogToDB(ex);
                Application.Restart();
                return;
            }
            FileManager.CreateTempFolder("CEDocs", true);

            //todo
            //JobManager.Job jobPublish = JobManager.Add("Yeni bir sürüm var!", 600, false);
            //jobPublish.Alert += jobPublish_Alert;


            JobManager.CheckAlerts();

            //todo
            //Reports reports = new Reports(nbReports, txtReportFilter, btnReportClearFilter);
            //CustomerBasedOperations cbo = new CustomerBasedOperations(nbCustomer, gleCustomer);
            //SeasonBasedOperations sbo = new SeasonBasedOperations(nbSeason, gleSeason);

            this.Persisting += MainForm_Persisting;
            this.UserChanged += MainForm_UserChanged;

            this.Show();

        }

        XForm x = new XForm();

        private void GridViewExtensions_Binding(DevExpress.XtraGrid.Views.Grid.GridView gridView, BindingSource bs)
        {
            x.InitGridView(gridView, bs);
        }

        
        void MainForm_Persisting()
        {
         
        }

        void MainForm_UserChanged()
        {
            FaturaRibbon.Init();
        }

    }
}